
#include "namedPipe.hpp"

// server -> read 管理命名管道的生命周期
int main()
{
    NamePipe fifo(comm_path, Creater);
    if (fifo.OpenForRead())
    {
        while (true)
        {
            std::string msg;
            int n = fifo.ReadNamedPipe(&msg);
            if (n > 0)
            {
                std::cout << "Client say > " << msg << std::endl;
            }
            else if (n == 0)
            {
                std::cout << "Client quit, server quit too!" << std::endl;
                break;
            }
            else
            {
                std::cerr << "ReadNamedPipe Error!" << std::endl;
                break;
            }
        }
    }

    return 0;
}